import re
from pathlib import Path


class WindowsPathValidator:
    def __init__(self):
        self.forbidden_pattern = re.compile(
            r'^([A-Z]:\\(Windows|Program Files|ProgramData)|\\\\\w+)',
            re.IGNORECASE
        )

    def is_allowed(self, path: str) -> bool:
        if self.forbidden_pattern.match(path):
            return False

        drive = Path(path).drive
        allowed_drives = config.windows.allowed_drives
        return drive.rstrip(':').upper() in [d.upper() for d in allowed_drives]